<?php
$this->breadcrumbs=array(
	'试卷管理'=>array('tests/'),
	$model->SID->subjectsTestsId->tests_name=>array('subjects/','testId'=>$_GET['testId']),
	$model->SID->subjects_title=>array('admin','tqId'=>$model->tests_question_sid,'testId'=>$_GET['testId']),
	'大题试题管理',
);
$this->menu=array(
	array('label'=>'新增', 'url'=>array('create','tqId'=>$model->tests_question_sid,'testId'=>$_GET['testId'])),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('tests-question-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<h1>
<?php
    $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
        'id'=>'qtAdd',
        'options'=>array(
            'title'=>'大题试卷复制',
            'autoOpen'=>false,
            'modal'=>true,
       ),
    ));
		$qModel=new Questions('search');
		$qModel->unsetAttributes();  // clear any default values
		$qModel->filterData();
		if(isset($_GET['Questions']))
			$qModel->attributes=$_GET['Questions'];

		$this->widget('zii.widgets.grid.CGridView', array(
		'id'=>'questions-grid',
		'dataProvider'=>$qModel->search(),
		'filter'=>$qModel,
		'columns'=>array(
			array(
				'name'=>'questions_title',
				'type'=>'raw',
				'value'=>'CHtml::link(CHtml::encode($data->questions_title), array("view","id"=>"$data->question_id"))',
				),
			array(
				'name'=>'questions_type',
				'value'=>'$data->getQTyptText()',
				//'value'=>$model->questions_type,
				'filter'=>$qModel->getQTypeOption(),
				),
			array(
					'class'=>'CButtonColumn',//CDataColumn, CLinkColumn, CButtonColumn  and CCheckBoxColumn.
					'buttons' => array(
							'newview' => array(
							    'label'=>'复制',     // text label of the button
							    'url'=>'array("Q2T","qId"=>"{$data->question_id}","tqId"=>"'.$model->tests_question_sid.'","testId"=>$_GET["testId"])', 
								'click'=>"function() {
									$.fn.yiiGridView.update('questions-grid',{
											type:'POST',
											url:$(this).attr('href'),
											success:function() {
												$.fn.yiiGridView.update('questions-grid');
												$.fn.yiiGridView.update('tests-question-grid');
											}
										});
										return false;
									}",
							),
						),
					'template' => '{newview}',
				),
			),
		));   

    $this->endWidget('zii.widgets.jui.CJuiDialog');

	echo CHtml::link('从题库中添加', '#', array(
            'onclick'=>'$("#qtAdd").dialog("open"); return false;',
    ));
?>
</h1>


<?php 

$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'tests-question-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'tests_question_title',
		'tests_question_type',
		/*
		'tests_question_qd',
		'tests_question_tid',
		'tests_question_sid',
		'tests_question_score',
		'tests_question_create_time',
		'tests_question_edit_time',
		*/
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>
